/** * Name: Ex L8b Eden-growth * Author: WALLENTIN, Gudrun * Description: CA Building block model to model dynamic environments * Eden growth */ model ExL8b_Edengrowth global { init { ask myCA[49,49]{ switch <- true; color <- rgb(255-cycle*3,200,cycle*1.5); } } reflex switch_{ //only consider cells that are already switched ask myCA where (each.switch = true){ //ask the empty neighbours of switched cells to switch with a 20% chance (alternative command: where (rnd(1.0) < 0.2)) ask neighbors where (flip(0.2) and each.switch = false) { switch <- true; color <- rgb(255-cycle*3,200,cycle*1.5); } } } } //The cellular automaton grid myCA width:100 height:100 neighbors:8 { bool switch; reflex calc{ grid_value <- self distance_to myCA[49,49]; } } //Simulation experiment simulation type:gui { output { display map type: opengl{ grid myCA; } display switched_cells type: 2d{ chart "Switched cells" type:series { data "Nb of switched cells" value: myCA count (each.switch = true); } } display distance type: java2D { // plot the max distance to the first switched cell chart "Distance" type: series { data "Max distance" color: rgb(255-cycle*3,200,cycle*1.5) value: max(myCA where(each.switch = true) collect each.grid_value); } } } }